package PVZ;

import javax.swing.*;
import java.awt.*;

public class MapRole extends JPanel {
    private static final int END=3;
    private static final int moveLeft=2;
    private static final int stop=1;
    private static final int moveRight=0;
    private static int move=moveRight;
    private static int x=0;
    private int a=0;
    public void Xrught(){
        if (move==moveRight){
            x--;
            if (x<=-500){
                move=stop;
            }
        }
        if (move==stop){
            a++;
            if (a>=200){
                move=moveLeft;
            }
        }
        if (move==moveLeft){
            if (x>=-120){
                move=END;
            }else {
                x++;
            }
        }
    }
    public boolean kill(){
        return move==END;
    }
    public void paintImage(Graphics g){
        Images.background.paintIcon(null, g, x, 0);
        Images.Zombie.paintIcon(null, g, 1400-200+x, 200);
        Images.FlagZombie.paintIcon(null, g, 1400-300+x, 300);
        Images.BucketheadZombie.paintIcon(null, g, 1400-350+x, 200);
        Images.ConeheadZombie.paintIcon(null, g, 1400-100+x, 350);
        Images.BucketheadZombie.paintIcon(null, g, 1400-100+x, 50);
        Images.FlagZombie.paintIcon(null, g, 1400-200+x, 20);
        Images.Zombie.paintIcon(null, g, 1400-170+x, 100);
        Images.ConeheadZombie.paintIcon(null, g, 1400-300+x, 20);
    }
}

